package com.zw.yzk.kabu.mapper;

import com.zw.yzk.kabu.data.network.entity.SearchTopicEntity;
import com.zw.yzk.kabu.model.SearchTopicModel;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

/**
 * Created by zhanwei on 2017/5/17.
 */

public class SearchTopicMapper {

    @Inject
    public SearchTopicMapper() {
    }

    public List<SearchTopicModel> transfer(SearchTopicEntity entity) {
        List<SearchTopicModel> result = new ArrayList<>();
        if (entity.result == null || entity.result.topicList == null) {
            return result;
        }
        for (SearchTopicEntity.Topic topic : entity.result.topicList) {
            SearchTopicModel model = new SearchTopicModel();
            model.setUserId(topic.userId);
            model.setImage(topic.image);
            model.setTopicId(topic.topicId);
            model.setTopicCosCount(topic.topicCosCount);
            model.setTopicUUID(topic.topicUUID);
            model.setTopicContent("#" + topic.topicContent + "#");
            model.setUserName(topic.userName);
            model.setTopicCosId(topic.topicCosId);
            model.setCreateTime(topic.createTime);

            result.add(model);
        }
        return result;
    }
}
